/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package entidade;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author bruno
 */
@Entity
@Table(name = "tipo_conta")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "TipoConta.findAll", query = "SELECT t FROM TipoConta t"),
    @NamedQuery(name = "TipoConta.findByIdTipoConta", query = "SELECT t FROM TipoConta t WHERE t.idTipoConta = :idTipoConta"),
    @NamedQuery(name = "TipoConta.findByNomeTipoConta", query = "SELECT t FROM TipoConta t WHERE t.nomeTipoConta = :nomeTipoConta")})
public class TipoConta implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @NotNull
    @Column(name = "idTipoConta")
    private Integer idTipoConta;
    @Size(max = 45)
    @Column(name = "nomeTipoConta")
    private String nomeTipoConta;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "idTipoConta")
    private Collection<Conta> contaCollection;

    public TipoConta() {
        this.idTipoConta = 0;
    }

    public TipoConta(Integer idTipoConta) {
        this.idTipoConta = idTipoConta;
    }

    public Integer getIdTipoConta() {
        return idTipoConta;
    }

    public void setIdTipoConta(Integer idTipoConta) {
        this.idTipoConta = idTipoConta;
    }

    public String getNomeTipoConta() {
        return nomeTipoConta;
    }

    public void setNomeTipoConta(String nomeTipoConta) {
        this.nomeTipoConta = nomeTipoConta;
    }

    @XmlTransient
    public Collection<Conta> getContaCollection() {
        return contaCollection;
    }

    public void setContaCollection(Collection<Conta> contaCollection) {
        this.contaCollection = contaCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idTipoConta != null ? idTipoConta.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof TipoConta)) {
            return false;
        }
        TipoConta other = (TipoConta) object;
        if ((this.idTipoConta == null && other.idTipoConta != null) || (this.idTipoConta != null && !this.idTipoConta.equals(other.idTipoConta))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return nomeTipoConta;
    }
    
}
